#include"com.hpp"
#include <sys/types.h>
#include <sys/stat.h>
int main()
{
    //创建命名管道；
    int n = mkfifo(FILE_PATH,MODE);
    if(n<0)
    {
        perror("mkfifo");
        exit(CREAT_FAIL);
    }

    char ch[1024] = {0};
    int fd = open(FILE_PATH,O_RDONLY);
    if(fd == -1)
    {
        perror("open");
        exit(OPEN_FAIL);
    }
    while(1)
    {

    
    int n = read(fd,ch,sizeof(ch));
    if(n<=0)
    {
        perror("read");
        exit(READ_FAIL);
    }
    ch[n] = '\0';
    cout<<"server say@"<<ch<<endl;
    if(strcmp(ch,"exit")==0)
    {
        break;
    }
    }
    //关闭文件描述符；
    close(fd);
    //rm namepipe;
    unlink(FILE_PATH);
    return 0;
}